package com.lmh.ymw.service.user;


import com.lmh.ymw.entity.User;
import com.lmh.ymw.mapper.user.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;
    @Override
    public boolean add(User user) {
        int i = userMapper.insertSelective(user);
        if (i != 0) {
            return  true;
        }else {
            return false;
        }
    }

    @Override
    public boolean update(User user) {
        int i = userMapper.updateByPrimaryKeySelective(user);
        if (i != 0) {
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean deleteUserById(Integer userId) {
        int i = userMapper.deleteByPrimaryKey(userId);
        if (i != 0) {
            return true;
        }else {
            return false;
        }
    }

    @Override
    public User getUser(String name, String pwd) {
        return userMapper.login(name, pwd);
    }

    @Override
    public List<User> getUserList() {
        List<User> users = userMapper.selectAll();
        return users;
    }

    @Override
    public User getSj(String sj) {
        return userMapper.getSj(sj);
    }
}
